-- msg_relic_boss_result
-- Create by cheny3
-- 通知遗迹BOSS挑战结果

return function(lpc)
    local para = lpc.result;

    -- 战斗结果
    trace("msg_relic_rob_result: ", tableToString(para));

    local relicBossInfo = ME.user.dbase:query("relic_boss_info", {});

    local result        = para.result;
    local attackerInfo  = para.attacker;
    local defenserInfo  = para.defenser;
    local record        = para.record;
    local bonus         = para.bonus;
    local leftHp        = para.left_hp;

    -- 抛出事件给UISkyRelicMain界面
    EventMgr.fire(event.RECEIVE_ROB_RESULT, {["battleInfo"] =
        {"boss", relicBossInfo["boss_id"], SkyRelicM.getRelicElementPos("boss", relicBossInfo["boss_id"])}});

    -- 处理当前结果
    if result ~= 1 then
        -- 失败了
        relicBossInfo["fail_times"] = tonumber(relicBossInfo["fail_times"]) + 1;
        relicBossInfo["last_fail"] = TimeM.getServerTime();
        -- 记录剩余血量
        relicBossInfo["left_hp"] = leftHp;
    else
        -- BOSS死亡了
        relicBossInfo["is_dead"] = 1;
        relicBossInfo["win_times"] = tonumber(relicBossInfo["win_times"]) + 1;
        -- 战绩系数增加
        relicBossInfo["combat_record"] = math.min(5, tonumber(relicBossInfo["combat_record"]) + 1);
        -- 删除位置信息
        SkyRelicM.deleteRelicPosInfoByType("boss", relicBossInfo["boss_id"]);
    end

    -- BOSS名字
    defenserInfo["name"] = SkyRelicM.queryBoss(relicBossInfo["boss_id"], "name");

    -- 标记是遗迹BOSS
    defenserInfo["relic_boss"] = true;

    -- 创建一个战场
    SkyCombatM.createBattle(attackerInfo, defenserInfo, result, record, bonus);

    -- 抛出刷新掠夺主图事件
    EventMgr.fire(event.RELIC_REFRESH_MAP, {});
end
